package com.yty.sms.message;

import com.yty.product.message.StockChanged;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.stereotype.Component;

@Component
@RabbitListener(bindings = {@QueueBinding(value = @Queue("product.sms"),//自动创建队列
        exchange = @Exchange(value = "product.fanout.productInfoChanged", type = ExchangeTypes.FANOUT))},
        containerFactory = "jsonMessageFactory")//绑定到交换机
@Slf4j
public class ProductMessageReceiver {
    /**
     * 库存变化
     *
     * @param stockChanged
     */
    @RabbitHandler
    public void processStockChanged(StockChanged stockChanged) {
        log.info("库存变化，{}", stockChanged);
        //给用户发短信，说现在库存不多了，赶紧入手...
    }
}
